const SET_USERNAME="SET_USERNAME";
const REMOVE_USER_INFO="REMOVE_USER_INFO";

const initState={user:"",token:"",dynamicRoutes:null}

export function User(state=initState,action) {
  switch (action.type) {
    case SET_USERNAME:
      return {...state,...action.payload};
    case REMOVE_USER_INFO:
      return {...initState};
    default:
      return state;
  }
}

// {user:"",token:""}
export function setUserInfo(userInfo) {
  return { type:SET_USERNAME,payload:userInfo };
}

export function removeUserInfo() {
  return { type:REMOVE_USER_INFO,payload:{}};
}

/*export function setUserName(user) {
  return dispatch=>{
    setTimeout(()=>{
      const action={ type:SET_USERNAME,payload:user };
      dispatch(action);
    },1000);
  }
}*/

